Solved

Error in PDF Writer name HOW to get it right ?


Userlevel 2
Badge +8

I am trying to write PDF file using PDF writer, when I add @Value(Scan_Location) in fanout dataset it creates 2 different files as output. And that is not what i want .

 

I just want this name ….20240621 NI2-HK-L03 As-built_PDMS Comparison Report F1.pdf 

and just one file 

 

 

 

 

icon

Best answer by redgeographics 24 June 2024, 14:55

View original

22 replies

Userlevel 2
Badge +11

Hi @vimva679, in this case you dont need a Fanout expression but just a normal path including your pdf file name. How about this one:

 

 

Normally I dont use PDF writers but this looks okay for your solution. It turns out red for now because the file path is not available on my desktop of course.

Userlevel 2
Badge +8

@lambertus thank you am not sure as the Scan location is dynamic value , so whatever is in scan location its should write that as file name . 

Userlevel 2
Badge +11

@vimva679 yes valid question, I updated my answer :) See above, I included Scan location and Timestamp as variables into the filename.

Be aware that the filename includes spaces right now, that can lead to an error probably

Userlevel 2
Badge +8

@lambertus nops it still creates 3 files 

 

 

Userlevel 2
Badge +8

 

Userlevel 2
Badge +8

I found a workaround with User parameter 

 

@Value(_timestamp) $(Scan_Location) As-built_PDMS Comparison Report $(FieldView_Number).pdf

 

thank you @lambertus so much :)

Userlevel 2
Badge +11

You're welcome :) 
You got 3 files by the way as output because you connected 3 lines with the FeatureWriter as separate inputs which will create 3 output files. 

In case you want just one file, create first the right output file with the transformers you need, then connect this output with one line to the FeatureWriter
 

Userlevel 2
Badge +8

I think am not getting it right , when i tried to rerun report with same setting , it generates error

 

i am having just one port connected and having Path as then below is report looking like 

 

 

PDF report 1 

C:\Users\vVaghani\Downloads\FME\10_PDMS_LST_Report_AI\03_Output_Data\@Value(_timestamp) @Value(Scan_Location) As-built_PDMS Comparison Report $(FieldView_Number).pdf

 

 

PDF report 2 

 

C:\Users\vVaghani\Downloads\FME\10_PDMS_LST_Report_AI\03_Output_Data\@Value(_timestamp) As-built_PDMS Comparison Report $(FieldView_Number).pdf

 

 

 

Userlevel 2
Badge +8

@daveatsafe Any idea why its not writing correct file name 

Userlevel 3
Badge +17

It seems to me that you may have two different values in the data for attribute ‘Scan Location’, so the data is being output to two different PDF files. I would recommend switching to an attribute whose value is consistent within the entire dataset, or ensuring that Scan Location consistent within the entire dataset.

One way to do this is to use a Sampler to separate the first feature from the rest, then use a VariableSetter to store the value of Scan Location. Send the rest of the features through a VariableRetriever to get the first feature’s Scan Location.

Userlevel 2
Badge +8

Thanks @daveatsafe not quite well , i tried using single input as well and it still create 2 PDF output, 1 blank and another with statistics. 

I think its got some issue with PDFPageFormatter 

 

 

Userlevel 5
Badge +32

Are you sure all your features are getting a timestamp (and all of them are getting the same timestamp)?

Userlevel 2
Badge +8

Here is test data and FME workbench test attached. Maybe you could have better insight @redgeographics @daveatsafe @lambertus 

Userlevel 2
Badge +8

I have tested it and come to conclusion that it is Creator instance that is causing problem or faulty ….highly appreciate with any workaround or suggestion 

 

 

Userlevel 5
Badge +32

As I said earlier: 

 

“Are you sure all your features are getting a timestamp (and all of them are getting the same timestamp)?”

 

If all the features going into the PDFPageFormatter have a timestamp -except- the one coming in from the Creator and you use that timestamp as part of your output file name you are indeed going to get two separate output files. Scroll up to your post from 2 days ago where you are showing 3 PDF files. The one selected does not have a timestamp in its name.

So check that. Inspect the output from 2C_db (which transformer is that anyway?) and see if it has a timestamp attribute.

And if you find that it doesn’t then you’ll need to make sure the timestamp gets added to all features you want to write to PDF. One way to do that is to use a bit of Python code in a scripted parameter, there was a post just last week by @nielsgerrits about exactly that.

Userlevel 2
Badge +8

yes all of them are getting the same timestamps and I have tested with both with and without timestamps , it still generates 2 files :(

 

 

Userlevel 5
Badge +32

Can you show me that the output of 2C_db has a timestamp?

Userlevel 2
Badge +8

I believe this is what you meant ? 

 the result is 2 files 

 

 

File 1 

 

File 2 

 

 

Userlevel 5
Badge +32

No, that is not what I meant.

 

See those little green magnifying glasses? They’re feature caches, allowing you to inspect the data at any point in your process. That way you can check which of the 6 features coming out of the PDFPageFormatter do not have a timestamp (although, since they are in File1, I’m certain it’s those two rectangles. And looking at the filename it looks like they’re misssing a lot of other attributes as well.

 

So that’s what you need to find out and fix. I must say it’s very hard trying to help you if every screenshot seems to be from a different workspace.

 

Oh, and do a Rerun entire workspace, trust me on this one, timestamps are notoriously difficult when feature caching is on.

Userlevel 2
Badge +8

:(  yes that true timestamps are horrible .It doesn’t get any closer in either all ways 

Userlevel 2
Badge +8

I think i found solution ...here is it how it will work …...atleast 1 column common that contains the same information :)

 

 

 

 

Userlevel 2
Badge +8

here is working FME workbench for community users, its perfectly working :)

Reply