Sign In  Sign Up Live-Chat

Open a pdf in C# for the user to view

Last post 09-15-2008, 3:24 PM by codewarior. 15 replies.
Page 1 of 2 (16 items)   1 2 Next >
Sort Posts: Previous Next
  •  09-10-2008, 11:51 AM 143377

    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
     
  •  09-10-2008, 3:23 PM 143420 in reply to 143377

    Re: Open a pdf in C# for the user to view

    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


    Nayyer Shahbaz
    Support Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-10-2008, 4:59 PM 143443 in reply to 143420

    Re: Open a pdf in C# for the user to view

    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

     

     
  •  09-10-2008, 5:59 PM 143448 in reply to 143443

    Re: Open a pdf in C# for the user to view

    Hi Joe,

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


    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-11-2008, 7:48 AM 143569 in reply to 143448

    Re: Open a pdf in C# for the user to view

    Attachment: Present (inaccessible)

    attached are the docs and pdf

    Thanks

     
  •  09-11-2008, 12:56 PM 143634 in reply to 143569

    Re: Open a pdf in C# for the user to view

    Attachment: Present (inaccessible)

    Hi,

    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.


    Nayyer Shahbaz
    Support Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-11-2008, 1:57 PM 143646 in reply to 143634

    Re: Open a pdf in C# for the user to view

    Attachment: Present (inaccessible)

    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


     

     
  •  09-11-2008, 2:46 PM 143655 in reply to 143634

    Re: Open a pdf in C# for the user to view

    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.

     
  •  09-11-2008, 3:55 PM 143671 in reply to 143655

    Re: Open a pdf in C# for the user to view

    Attachment: Present (inaccessible)

    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");


    Nayyer Shahbaz
    Support Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-11-2008, 4:42 PM 143679 in reply to 143671

    Re: Open a pdf in C# for the user to view

    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

     
  •  09-11-2008, 5:28 PM 143685 in reply to 143377

    Re: Open a pdf in C# for the user to view

    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

     
  •  09-12-2008, 8:31 AM 143814 in reply to 143685

    Re: Open a pdf in C# for the user to view

    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

     
  •  09-12-2008, 1:41 PM 143867 in reply to 143671

    Re: Open a pdf in C# for the user to view

    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

     
  •  09-12-2008, 3:43 PM 143885 in reply to 143867

    Re: Open a pdf in C# for the user to view

    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.


    Nayyer Shahbaz
    Support Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-15-2008, 8:14 AM 144037 in reply to 143885

    Re: Open a pdf in C# for the user to view

    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

     
Page 1 of 2 (16 items)   1 2 Next >
View as RSS news feed in XML