Opening Non-PDF files
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Opening Non-PDF files
The ability to open non-PDF files using the OpenDocFromPath is very nice. It allows me to convert a lot of non-PDF files to PDF.
However, I was wondering about some options that may control the PDF page size when converting to PDF upon open.
For example, the attached file contains two TIF files, one that is 1700x2200pixels and there the second is 1728x2255pixeks. When I open them using OpenDocFromPath, the first gets converted to 612x792points/8.5x11inches (which is what I expected) but the second gets converted to 414.7x541.2points/5.76x7.52inches (much smaller than expected).
Why does the second on get reduced so small. I would have expected it to be bigger than the first. What is your algorithm to determine PDF page size when opening non-PDF files? And are there any options to specify what page size I desire?
For example, let's say I have some small images but want them always converted to US Letter page size when opened in PDF?
Thanks.
--Jeff
However, I was wondering about some options that may control the PDF page size when converting to PDF upon open.
For example, the attached file contains two TIF files, one that is 1700x2200pixels and there the second is 1728x2255pixeks. When I open them using OpenDocFromPath, the first gets converted to 612x792points/8.5x11inches (which is what I expected) but the second gets converted to 414.7x541.2points/5.76x7.52inches (much smaller than expected).
Why does the second on get reduced so small. I would have expected it to be bigger than the first. What is your algorithm to determine PDF page size when opening non-PDF files? And are there any options to specify what page size I desire?
For example, let's say I have some small images but want them always converted to US Letter page size when opened in PDF?
Thanks.
--Jeff
- Attachments
-
- Test.zip
- (88.54 KiB) Downloaded 66 times
- Tracker Supp-Stefan
- Site Admin
- Posts: 17938
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Opening Non-PDF files
Hi Jeff,
One of your files is 200dpi - and this gets converted to the correct Letter page size (1700 / 200 = 8.5 inch). The other one is 300 dpi (1728 / 300 = 5.76 inch), and that's why it's dimensions in inches are smaller than for the other one with less pixels. I am not aware of a way you can control what DPI should be used, and am not sure if there is one, so I will need to check with my colleagues from the dev team. We will update this topic as soon as possible.
Regards,
Stefan
One of your files is 200dpi - and this gets converted to the correct Letter page size (1700 / 200 = 8.5 inch). The other one is 300 dpi (1728 / 300 = 5.76 inch), and that's why it's dimensions in inches are smaller than for the other one with less pixels. I am not aware of a way you can control what DPI should be used, and am not sure if there is one, so I will need to check with my colleagues from the dev team. We will update this topic as soon as possible.
Regards,
Stefan
Re: Opening Non-PDF files
Ok. That makes sense now. I didn't realize the second image was 300 dpi.
But it would still be nice to specify the default page size.
--Jeff
But it would still be nice to specify the default page size.
--Jeff
- Tracker Supp-Stefan
- Site Admin
- Posts: 17938
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Opening Non-PDF files
Hi Jeff,
Yes it would be. I've already asked my colleagues for help with answering that part and if there is a way - we will post it here.
Regards,
Stefan
Yes it would be. I've already asked my colleagues for help with answering that part and if there is a way - we will post it here.
Regards,
Stefan
- Ivan - Tracker Software
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: Opening Non-PDF files
I'm afraid we cannot promise such feature for converters in general case because supporting such feature for different kind of formats might not be possible.
In your case, you can use op.imagesToDoc operation, where you can specify how images should be placed on the pages.
In your case, you can use op.imagesToDoc operation, where you can specify how images should be placed on the pages.
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Re: Opening Non-PDF files
Yes, op.imagesToDoc looks promising.
Do you by chance have any sample code that uses this so I can get a better look at how you are setting up the options.
In my case, I'd want to create a blank PDF page with dimensions specified by my user and then insert an image onto that page. Sometimes I'd want it to scale the full size of the page and sometimes just place it in the upper left corner, etc.
--Jeff
Do you by chance have any sample code that uses this so I can get a better look at how you are setting up the options.
In my case, I'd want to create a blank PDF page with dimensions specified by my user and then insert an image onto that page. Sometimes I'd want it to scale the full size of the page and sometimes just place it in the upper left corner, etc.
--Jeff
- Tracker Supp-Stefan
- Site Admin
- Posts: 17938
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Opening Non-PDF files
Hello Jeff,
In the Editor Full Demo project under "Operations" there is a "Images To Document" sample - please look at the code of this
Cheers,
Stefan
In the Editor Full Demo project under "Operations" there is a "Images To Document" sample - please look at the code of this
Cheers,
Stefan
Re: Opening Non-PDF files
I'm using Delphi so sometimes it's a bit difficult for me to find my way around your C# code in the full demo, but after taking a look, it appears that the Images to Document sample is just displaying a build in dialog containing those options.
I'm looking for some C# code that is actually making the op.imagesToDoc call and programatically setting some of the options. I have my own options dialogs so I just need a way to transfer the options directlyh in code.
Am I missing something? Is there a specific .cs file I should be looking at in the full demo source?
Also, it looks like your scanning is done in the images to document context. Are there some calls into your scanning code I can make directly to launch a scan from within my program without having to use your built in dialog?
Thanks.
--Jeff
I'm looking for some C# code that is actually making the op.imagesToDoc call and programatically setting some of the options. I have my own options dialogs so I just need a way to transfer the options directlyh in code.
Am I missing something? Is there a specific .cs file I should be looking at in the full demo source?
Also, it looks like your scanning is done in the images to document context. Are there some calls into your scanning code I can make directly to launch a scan from within my program without having to use your built in dialog?
Thanks.
--Jeff
Re: Opening Non-PDF files
Perhaps my working code would help here.
Below is my procedure to convert an image file into a PDF using op.imagesToDoc
I get an exception when trying to save out the PDF file;
I'm happy to use either Option 1 or Options 2 below but need help in setting this up right.
Below is my procedure to convert an image file into a PDF using op.imagesToDoc
I get an exception when trying to save out the PDF file;
I'm happy to use either Option 1 or Options 2 below but need help in setting this up right.
Code: Select all
procedure TMyPDF.ImageToDocEx(AInputFile, AOutputFile: String);
var
nID: integer;
pOp: IOperation;
output: ICabNode;
input: ICabNode;
target: ICabNode;
options: ICabNode;
imgPath: IAFS_Name;
ATargetDoc: IPXC_Document;
begin
SetExceptionMask(exAllArithmeticExceptions);
nID := INST_PXV.Str2ID('op.imagesToDoc', False);
pOp := INST_PXV.CreateOp(nID);
imgPath := INST_AFS.DefaultFileSys.StringToName(PChar(AInputFile), 0, nil);
input := pOp.Params.Root['Input'];
input.Add(dt_IUnknown).v := imgPath;
options := pOp.Params.Root['Options'];
options['KeepAspect'].v := True;
//Option 1 - How do I place the Outlput in ATargetDoc??
//output := pOp.Params.Root['Output'];
//Option 2 - Set Options.TargetDoc to ATargetDoc
ATargetDoc := INST_PXC.NewDocument;
target := pOp.Params.Root['Options.TargetDoc'];
target['DocID'].v := ATargetDoc.ID;
target['Location'].v := 1;
pOp.Do_(0);
ATargetDoc.WriteToFile(PChar(AOutputFile), nil, 0);
end;
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Opening Non-PDF files
Hello Jeff,
Please look at other operation samples and set the imagesToDoc parameters accordingly - they are almost all documented and should not be that hard to fill. Also, here's the topic where this operation is being called:
https://www.pdf-xchange.com/forum3 ... oc#p103658
As for the direct scan launching - there is a op.scanToImages operation. Though it's not documented yet because it is a very big operation and requires a great amount of time of the developer who wrote it to write the description. Though we will try to update this in the nearest future.
Cheers,
Alex
Please look at other operation samples and set the imagesToDoc parameters accordingly - they are almost all documented and should not be that hard to fill. Also, here's the topic where this operation is being called:
https://www.pdf-xchange.com/forum3 ... oc#p103658
As for the direct scan launching - there is a op.scanToImages operation. Though it's not documented yet because it is a very big operation and requires a great amount of time of the developer who wrote it to write the description. Though we will try to update this in the nearest future.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Opening Non-PDF files
As for your last post - the output of the operation is what the operation returns after the successful Do(). You don't need to fill it.
As for the option 2 - better use the NewDoc dictionary not the TargetDoc.
Cheers,
Alex
As for the option 2 - better use the NewDoc dictionary not the TargetDoc.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Opening Non-PDF files
Can you show me in the Delphi code above how to get ATargetDoc assigned to the output of the Do(0);the output of the operation is what the operation returns after the successful Do().
I can't figure that out.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Opening Non-PDF files
The output should be read after successful Do. You should not fill it before the operation. If needed the Output is being filled by the Do() method of the operation itself. For example this operation's sample illustrates how the Output is used:
https://sdkhelp.pdf-xchange.com/vie ... ewBlankDoc
Cheers,
Alex
https://sdkhelp.pdf-xchange.com/vie ... ewBlankDoc
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Opening Non-PDF files
Ok. I'm really close. I just can get the typecast right for the output. The following code compiles but errors out at the line
ATargetDoc := IUnknown(pOp.Params.Root['Output'].v) as IPXC_Document;
I followed your op.newBlankDoc example, but the type casts in Delphi are sometimes problematic.
Can your Delphi expert help me on this one?
--Jeff
ATargetDoc := IUnknown(pOp.Params.Root['Output'].v) as IPXC_Document;
Code: Select all
procedure TMyPDF.ImageToDocEx(AInputFile, AOutputFile: String);
var
nID: integer;
pOp: IOperation;
output: ICabNode;
input: ICabNode;
new: ICabNode;
options: ICabNode;
imgPath: IAFS_Name;
ATargetDoc: IPXC_Document;
begin
nID := INST_PXV.Str2ID('op.imagesToDoc', False);
pOp := INST_PXV.CreateOp(nID);
imgPath := INST_AFS.DefaultFileSys.StringToName(PChar(AInputFile), 0, nil);
input := pOp.Params.Root['Input'];
input.Add(dt_IUnknown).v := imgPath;
options := pOp.Params.Root['Options'];
options['KeepAspect'].v := True;
pOp.Do_(0);
ATargetDoc := IUnknown(pOp.Params.Root['Output'].v) as IPXC_Document;
ATargetDoc.WriteToFile(PChar(AOutputFile), nil, 0);
end;
Can your Delphi expert help me on this one?
--Jeff
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Opening Non-PDF files
Hello Jeff,
I will send him this question, though he will be able to look at this on Monday.
Cheers,
Alex
I will send him this question, though he will be able to look at this on Monday.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Opening Non-PDF files
Hello Jeff,
Our Delphi expert is ill right now. He will answer this when he gets better.
Cheers,
Alex
Our Delphi expert is ill right now. He will answer this when he gets better.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ