We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Open a pdf in C# for the user to view

All I want to do is open a pdf for the user to view and or print the document.

Where would I find an example or 2?

Thanks


This message was posted using Page2Forum from Aspose.Form - Aspose.Pdf for .NET and Java

Hi,

Thanks for considering Aspose.

You can view and print the pdf document using PdfViewer class of Aspose.Pdf.Kit. But before providing any example I would like to share something, PdfViewer is in Beta version and some of the features may not work properly, also viewing the Pdf is not supported well & you need to use some other software like Adobe Reader.

For more information please visit http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/pdfviewer.html

Thanks,

I figured it out.

However,

When I convert a .doc to .pdf I lose the header, footer and barcode.

I am using your example of merginf multiple .docs into 1 .pdf because that is what the system requires.

Please help.

Thanks,

Joe

Hi Joe,

Can you please provide the doc file and let us check it?

attached are the docs and pdf

Thanks

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have tested the issue and I am unable to reproduce the problem. I have tested the issue using Aspose.Words v5.2.2.0 and Aspose.Pdf v3.8.0.0. The resultant file is in attachment.

For word to Pdf conversion I have used the following code snippet.

Document doc = new Document(@"C:\pdftest\aspose\sample2.doc");
doc.Save(@"C:\pdftest\aspose\sample2.xml", SaveFormat.AsposePdf);

// New a pdf object
Aspose.Pdf.Pdf pdf11 = new Aspose.Pdf.Pdf();

// Bind content from the named xml file.
pdf11.BindXML(@"C:\pdftest\aspose\sample2.xml", null);

// Call the function to convert all fonts to Unicode
pdf11.SetUnicode();

pdf11.IsImagesInXmlDeleteNeeded = true;
pdf11.Save(@"C:\pdftest\aspose\sample2.pdf");

I am not sure what technique you have used, in my scenario, first I have converted both the document to Pdf and than merged them using Aspose.Pdf.Kit. In case the issue still persists, feel free to share.

HI,

Thanks for the quick response.

Here is my code ::

if (ii == 0) // this is for the first document only
{
pdf_name = cds[1];
Aspose.Words.Document doc = new Aspose.Words.Document(Server.MapPath("~") + "\\temp\\" + cds[1] + ".doc");
doc.Save(Server.MapPath("~") + "\\temp\\" + cds[1] + ".xml", SaveFormat.AsposePdf);
pdf1.BindXML(Server.MapPath("~") + "\\temp\\" + cds[1] + ".xml", null);
}
else // this is for documents 2 - ....
{
Aspose.Pdf.Pdf pdf2 = new Aspose.Pdf.Pdf();
Aspose.Words.Document doc = new Aspose.Words.Document(Server.MapPath("~") + "\\temp\\" + cds[1] + ".doc");
doc.Save(Server.MapPath("~") + "\\temp\\" + cds[1] + ".xml", SaveFormat.AsposePdf);
pdf2.BindXML(Server.MapPath("~") + "\\temp\\" + cds[1] + ".xml", null);
foreach (Aspose.Pdf.Section sec in pdf2.Sections)
{
pdf1.Sections.Add(sec);
}
}

Now here is a new twist.

I combined 4 documents set 1 and 2 are identical.

when I did the merge, the first 2 had the image header and footer and barcode missing the next set of 2 were ok. I am attaching the samples for you to look at.

If you see where I should fix my code let me know. I did take the original code example from your site and modified it to our files names etc.

Thanks again,

Joe


I tested my scenario with the 2 lines that you suggested that I don't have which are:

SetUnicode and

DeleteNeeded

To no avail. Still didn't convert the header and/or footer and barcode.

Thanks,

Joe

Once I get this going we can go live with the new improved system.

Hi Joe,

I have again tested the scenario and I am unable to reproduce the problem. The resultant file is in attachment. The only difference in our code is that, I am not using server relative paths, in fact I am using path to resource files over my hard drive.

[C#]

Document doc = new Document(@"C:\pdftest\issueDocuments\sampleb.doc");
doc.Save(@"C:\pdftest\issueDocuments\sampleb.xml", SaveFormat.AsposePdf);

// New a pdf object
Aspose.Pdf.Pdf pdf11 = new Aspose.Pdf.Pdf();
// Bind content from the named xml file.
pdf11.BindXML(@"C:\pdftest\issueDocuments\sampleb.xml", null);

// Call the function to convert all fonts to unicode
pdf11.SetUnicode();
pdf11.IsImagesInXmlDeleteNeeded = true;

// Convert Second document and Merge its Sections into First pdf instance

Document doc1 = new Document(@"C:\pdftest\issueDocuments\samplea.doc");
doc1.Save(@"C:\pdftest\issueDocuments\samplea.xml", SaveFormat.AsposePdf);

Aspose.Pdf.Pdf pdf12 = new Aspose.Pdf.Pdf();
pdf12.BindXML(@"C:\pdftest\issueDocuments\samplea.xml", null);
pdf12.SetUnicode();
pdf12.IsImagesInXmlDeleteNeeded = true;

foreach (Aspose.Pdf.Section sec in pdf12.Sections)
{
pdf11.Sections.Add(sec);
}

//Convert Third document and Merge its Sections into First pdf instance

Document doc2 = new Document(@"C:\pdftest\issueDocuments\sampled.doc");
doc2.Save(@"C:\pdftest\issueDocuments\sampled.xml", SaveFormat.AsposePdf);

Aspose.Pdf.Pdf pdf13 = new Aspose.Pdf.Pdf();
pdf13.BindXML(@"C:\pdftest\issueDocuments\sampled.xml", null);
pdf13.SetUnicode();
pdf13.IsImagesInXmlDeleteNeeded = true;

foreach (Aspose.Pdf.Section sec in pdf13.Sections)
{
pdf11.Sections.Add(sec);
}

// Convert Fourth document and Merge its Sections into First pdf instance

Document doc3 = new Document(@"C:\pdftest\issueDocuments\samplec.doc");
doc3.Save(@"C:\pdftest\issueDocuments\samplec.xml", SaveFormat.AsposePdf);

Aspose.Pdf.Pdf pdf14 = new Aspose.Pdf.Pdf();
pdf14.BindXML(@"C:\pdftest\issueDocuments\samplec.xml", null);
pdf14.SetUnicode();
pdf14.IsImagesInXmlDeleteNeeded = true;

foreach (Aspose.Pdf.Section sec in pdf14.Sections)
{
pdf11.Sections.Add(sec);
}

// Save the final Pdf document, containing sections of all documents

pdf11.Save(@"C:\pdftest\issueDocuments\sampleb.pdf");

The server map path converts to an actual address so I don't see why it would make a difference.

That is what I use everywhere in the system and it works correctly.

If I don't get it to work I'll have to buy another product. The pressure is on me.

Thanks

Joe

GUess What?? I got it to work properly.

My fault. I was deleting the work files before the save step.

However, If you look back at samplec.doc and samplee.pdf you will notice on the status request forms at the bottom the signature,date and email is spaced properly on the .doc but scrunched together on the .pdf.

Sorry to bother you guys but you know what happens when the pressure is on.

Thanks for your patience and I hope I never have to talk with you again (umless I am coming down under),

Joe

Alex,

It appears that in converting from .doc to .pdf the tabs are not converting properly.

I replaced the tabs in the statusrequest document samplec.doc with spaces and rand the pdf convert and it formatted properly. I have about 50 forms to manually change if aspose doesn't have a fix for this.

Thanks

Joe

I Just want to clarify the tabs issue.

It is not for a line that begins with tabs but rather

a line that has tabs, some data, more tabs, more data

the "more tabs" are the ones not converting.

Joe

Hello Joe,

Can you please point out the exact location in Doc file for which the resultant pdf is missing the Tabs. I am afraid I cannot figure out where the problem is. As far as I can see, Signature, Date and email address, all are being properly rendered at appropriate positions in the pdf.

if you open samplec go down to the line that states "0-90 Days, 91-180", etc and compare that to page 2 of samplee the pdf document. You will see that the horizontal spacing is different.

Then go to the line that states "Attorney Signature", "Date" etc. You will see that Date on samplec begins in column 40 and "email address" begins in column 56. If you look at the samplee page 2 (same as above) you will see the difference.

If you turn on "show formatting" in word it will reveal where the tabs are in samplec.

Hope this helps,

Joe

Hello Joe,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have again tested the scenario, but I am unable to figure out the exact problem that you have highlighted. As far as I can notice, there is very minor spacing issue in the resultant file. The only major difference that can be noticed is, in the address at the bottom, where spacing between the characters in word file is different than in Pdf file.

I have attached the screenshot of both the files, and have marked lines to show the alignment. Please take a review.