Jump to content
Lau13

Guardar informação em PDF

Recommended Posts

Lau13

Boa noite. Estou com um problema no meu programa, eu queria guardar está informação num ficheiro pdf, e ele guarda mas quando vou a abrir aparece-me a seguinte mensagem de erro: E5W0fbD.png

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       SaveFileDialog1.Title = "Guardar Ficheiro"
       SaveFileDialog1.DefaultExt = "pdf"
       If SaveFileDialog1.ShowDialog = DialogResult.OK Then
           If RadioButton1.Checked = True Or RadioButton2.Checked = True Or RadioButton3.Checked = True Or RadioButton4.Checked = True Or RadioButton5.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, "Página dos Cursos" + Environment.NewLine + Environment.NewLine)
           If RadioButton1.Checked = True Or RadioButton2.Checked = True Or RadioButton3.Checked = True Or RadioButton4.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, Label_A.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton1.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, RadioButton1.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton2.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, RadioButton2.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton3.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, RadioButton3.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton4.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, RadioButton4.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton5.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, Label_B.Text + Environment.NewLine + Environment.NewLine)
           If RadioButton5.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, RadioButton5.Text + Environment.NewLine + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, "Página de Identificação do Aluno" + Environment.NewLine + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_1.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, a.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_2.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ComboBox_1.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_3.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ComboBox_2.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_4.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ComboBox_3.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_5.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, b.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_6.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, c.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_7.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, DateTimePicker1.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_8.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, DateTimePicker2.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_9.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, d.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_10.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ee.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_11.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, f.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_12.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, g.Text)
           File.AppendAllText(SaveFileDialog1.FileName, Label_13.Text)
           File.AppendAllText(SaveFileDialog1.FileName, h.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_14.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, i.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_15.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, j.Text + Environment.NewLine)
           If CheckBox1.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, Label_16.Text + "  ")
           If CheckBox1.Checked = True Then File.AppendAllText(SaveFileDialog1.FileName, CheckBox1.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_17.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, k.Text + " ")
           File.AppendAllText(SaveFileDialog1.FileName, Label_18.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, i.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_19.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, m.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_20.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, n.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_21.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ComboBox_4.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_22.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, ComboBox_5.Text + Environment.NewLine + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, "Página de Identificação do Encarregado de Educação" + Environment.NewLine + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_23.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, o.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_24.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, p.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_25.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, q.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_26.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, r.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_27.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, s.Text)
           File.AppendAllText(SaveFileDialog1.FileName, Label_28.Text)
           File.AppendAllText(SaveFileDialog1.FileName, t.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_29.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, u.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_30.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, v.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_31.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, x.Text + Environment.NewLine)
           File.AppendAllText(SaveFileDialog1.FileName, Label_32.Text + "  ")
           File.AppendAllText(SaveFileDialog1.FileName, z.Text + Environment.NewLine)
       End If
   End Sub

Edited by thoga31
GeSHi

Share this post


Link to post
Share on other sites
renafi

Não consegues escrever directamente para um ficheiro Pdf.... eles têm metadados internos que não funcionam de uma forma simples.

Experimenta abrir esse ficheiro com o Notepad, e vê se abre. O conteúdo do ficheiro é texto puro.

Para escrever para um ficheiro Pdf, tens de utilizar livrarias específicas. Experimenta o ItextShap: http://sourceforge.net/projects/itextsharp/

Algum problema, vai dizendo.

  • Vote 1

Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist

Share this post


Link to post
Share on other sites
renafi

Boas Nelsonr. Mas sabes quais são as limitações? O PDFSharp é porreiro também?

Boas,

eu utilizo o PDFSharp.

O iTextSharp tem algumas limitações a nivel de licença comercial.

Se utilizares um componente externo (ex: iTextSharp ou PDFSharp), basta criares um objecto desse tipo e tem lá métodos para adicionares texto.

Exemplo do PDFSharp:

http://www.pdfsharp.net/wiki/HelloWorld-sample-VB.ashx


Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist

Share this post


Link to post
Share on other sites
nelsonr
Boas Nelsonr. Mas sabes quais são as limitações? O PDFSharp é porreiro também?

Sei que as versões iniciais eram de uso grátis, mas as mais recentes impõem limites no uso comercial.

Por exemplo, aqui tens:

http://itextpdf.com/terms-of-use/index.php

Buying such a license is mandatory as soon as you develop commercial activities distributing the iText software inside your product or deploying it on a network without disclosing the source code of your own applications under the AGPL license.

Enquanto que com o PDFSharp

http://www.pdfsharp.net/Licensing.ashx

- PDFsharp and MigraDoc Foundation are Open Source and free to use

- Copy, modify and integrate the source code of PDFsharp and MigraDoc Foundation in your applications without restrictions at all

- This also applies to commercial products (both Open Source and Closed Source)

- PDFsharp and MigraDoc Foundation will remain Open Source and free to use even in the far future

A nivel de "features", para o que eu precisei (criar PDFs simples com texto e imagens), o PDFSharp fazia na boa, e até mais simples que o iTextSharp

Share this post


Link to post
Share on other sites
crax15

Por exemplo se eu tiver ficheiros em PDF mas têm campos "editaveis". (ou seja, queria passar de formato em papel para formato digital) e queria preencher esses dados numa aplicação, é possivel?


Pedro'O

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.